<?php

if(!isset($_SESSION)) 
{ 
session_start(); 
} 

//$field = $_REQUEST['field'];
$carnumber = $_REQUEST['checkcarcrime'];

include '../../connection/connection_crimecar.php';
$selectcarcrime = mysql_query("select a.carnumber,a.camera_id,co.id,co.name,co.host,co.go_mode,a.filename,d.cartype,d.code1,co.pos_x,co.pos_y 
			from alarm_display a,favourite f,configcamera co,alarm_dat d 
			where a.carnumber=d.carnumber and co.id=f.camera_ID and co.id=a.camera_id GROUP BY a.carnumber",$connection_crimecar);

		if(mysql_num_rows($selectcarcrime)!=0){
		?>
	    	<ul class="plist">
	    	<?php 
	    	$userid= $_SESSION['iduser'];
			include '../../value/value_kr.php';
			
	    	$i=0;
		 	while ($row = mysql_fetch_array($selectcarcrime)){
			 	$i++;
			  	$datetime = explode("_",$row[filename]);
			  	$tempdate = strtotime($datetime[0]);
			  	$y = date("Y",$tempdate);
			  	$d = substr($datetime[0], -2);
			  	$ymd = date("Ymd",$tempdate);
			  	
			  	$temphour = strtotime($datetime[1]);
			  	$h = date("H",$temphour);
			  	$m = date("i",$temphour);
			  	$s = date("s",$temphour);
			  	
		 	if ($i==1) {
			  		$imga = "http://".$row[host]."/".$y."/".$ymd."/".$h."/".$m."/".$row[filename];
			  	}
			  	?>
		        	<li>
		            	<input type="checkbox"  name="checkcarcrime[<?=$i?>]" class="checkcarcrime"
			            	id="<?php echo 'checkcarcr'.$i?>" onclick="processCheck(this.id);"
				            
		            		value="<?=$row[carnumber];?>"/> <?=$row[carnumber];?>
		                <?=$row[name]."--";?><?php if ($row[go_mode]==0){echo $l_go;}else {echo $l_come;}?>
		  					<?="--".$row[cartype]."--".$y."-".$d."    ".$h."-".$m."-".$s?>
		  					<input type="hidden" name="carnumber" id="carnumber" value="<?=$row[carnumber]?>">
		  					<?php $_SESSION['cameraid'] = $row['camera_id'];?>
		                <div class="clear"></div>
		           </li>
	              <?php }
	              if(isset($imga)){
	              	echo "<div class='imga' style='visibility: hidden;'>".$imga."</div>";
	              }
	              ?>
	        </ul>
	   
	    <?php
		}else{?>
	    <div></div>
	    <?php 
	    }?>
	   <?php mysql_close($connection_crimecar);?>